FROM centos:8

LABEL maintainer="llww" \
    provider="llww."


# Do not use alias cp
RUN \cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && rm -rf /etc/yum.repos.d/* \

    && echo "[base]" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "name=CentOS-\$releasever - Base - mirrors.aliyun.com" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "failovermethod=priority" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "baseurl=https://mirrors.aliyun.com/centos/\$releasever/BaseOS/\$basearch/os/" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "        http://mirrors.aliyuncs.com/centos/\$releasever/BaseOS/\$basearch/os/" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "        http://mirrors.cloud.aliyuncs.com/centos/\$releasever/BaseOS/\$basearch/os/" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "gpgcheck=1" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "#additional packages that may be useful" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "[extras]" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "name=CentOS-\$releasever - Extras - mirrors.aliyun.com" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "failovermethod=priority" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "baseurl=https://mirrors.aliyun.com/centos/\$releasever/extras/\$basearch/os/" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "        http://mirrors.aliyuncs.com/centos/\$releasever/extras/\$basearch/os/" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "        http://mirrors.cloud.aliyuncs.com/centos/\$releasever/extras/\$basearch/os/" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "gpgcheck=1" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "#additional packages that extend functionality of existing packages" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "[centosplus]" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "name=CentOS-\$releasever - Plus - mirrors.aliyun.com" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "failovermethod=priority" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "baseurl=https://mirrors.aliyun.com/centos/\$releasever/centosplus/\$basearch/os/" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "        http://mirrors.aliyuncs.com/centos/\$releasever/centosplus/\$basearch/os/" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "        http://mirrors.cloud.aliyuncs.com/centos/\$releasever/centosplus/\$basearch/os/" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "gpgcheck=1" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "enabled=0" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "[PowerTools]" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "name=CentOS-\$releasever - PowerTools - mirrors.aliyun.com" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "failovermethod=priority" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "baseurl=https://mirrors.aliyun.com/centos/\$releasever/PowerTools/\$basearch/os/" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "        http://mirrors.aliyuncs.com/centos/\$releasever/PowerTools/\$basearch/os/" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "        http://mirrors.cloud.aliyuncs.com/centos/\$releasever/PowerTools/\$basearch/os/" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "gpgcheck=1" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "enabled=0" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "[AppStream]" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "name=CentOS-\$releasever - AppStream - mirrors.aliyun.com" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "failovermethod=priority" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "baseurl=https://mirrors.aliyun.com/centos/\$releasever/AppStream/\$basearch/os/" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "        http://mirrors.aliyuncs.com/centos/\$releasever/AppStream/\$basearch/os/" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "        http://mirrors.cloud.aliyuncs.com/centos/\$releasever/AppStream/\$basearch/os/" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "gpgcheck=1" >> /etc/yum.repos.d/CentOS-Base.repo \
    && echo "gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official" >> /etc/yum.repos.d/CentOS-Base.repo \

#    && yum update -y \
#    && yum makecache \
    ## 安装应用
    && yum install -y  passwd \
    && yum install -y  telnet \
    && yum install -y  lsof \
    && yum install -y  openssh-server \
    && yum install -y  wget \
    && yum install -y  which \
    && yum install -y  maven \
    && yum install -y  vim \
    && yum install -y  java-11-openjdk-devel.x86_64 \
    && yum install -y  git \
    && yum install -y  net-tools \

    ## 别名
    && echo "alias cp='cp -i'" >> /etc/bashrc \
    && echo "alias kill9='kill -9'" >> /etc/bashrc \
    && echo "alias egrep='egrep --color=auto'" >> /etc/bashrc \
    && echo "alias fgrep='fgrep --color=auto'" >> /etc/bashrc \
    && echo "alias grep='grep --color=auto'" >> /etc/bashrc \
    && echo "alias l.='ls -d .* --color=auto'" >> /etc/bashrc \
    && echo "alias ll='ls -l --color=auto'" >> /etc/bashrc \
    && echo "alias ls='ls --color=auto'" >> /etc/bashrc \
    && echo "alias mv='mv -i'" >> /etc/bashrc \
    && echo "alias rm='rm -i'" >> /etc/bashrc \
    && echo "alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'" >> /etc/bashrc \
    && echo "alias xzegrep='xzegrep --color=auto'" >> /etc/bashrc \
    && echo "alias xzfgrep='xzfgrep --color=auto'" >> /etc/bashrc \
    && echo "alias xzgrep='xzgrep --color=auto'" >> /etc/bashrc \
    && echo "alias zegrep='zegrep --color=auto'" >> /etc/bashrc \
    && echo "alias zfgrep='zfgrep --color=auto'" >> /etc/bashrc \
    && echo "alias zgrep='zgrep --color=auto'" >> /etc/bashrc \
    && echo "alias pub='ssh-keygen;echo 公钥为;cat ~/.ssh/id_rsa.pub '" >> /etc/bashrc \

    ## 环境变量
    && echo "export JAVA_HOME='/etc/alternatives/java_sdk_11_openjdk'" >> /etc/bashrc \
    && echo 'export PATH="${JAVA_HOME}/bin:${PATH}"' >> /etc/bashrc \


    ## 设置root密码
    && echo "root" | passwd --stdin root \
    && groupadd -r llww && useradd -g llww llww \
    && echo "llww" | passwd --stdin llww \


    ## maven ali仓库配置
    && mkdir -p /root/.m2 \
    && echo "<?xml version="1.0" encoding="UTF-8"?>" >> /root/.m2/settings.xml \
    && echo "<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"" >> /root/.m2/settings.xml \
    && echo "          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"" >> /root/.m2/settings.xml \
    && echo "          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">" >> /root/.m2/settings.xml \
    && echo "    <mirrors>" >> /root/.m2/settings.xml \
    && echo "        <mirror>" >> /root/.m2/settings.xml \
    && echo "            <id>ali</id>" >> /root/.m2/settings.xml \
    && echo "            <mirrorOf>central</mirrorOf>" >> /root/.m2/settings.xml \
    && echo "            <url>https://maven.aliyun.com/repository/public</url>" >> /root/.m2/settings.xml \
    && echo "        </mirror>" >> /root/.m2/settings.xml \
    && echo "    </mirrors>" >> /root/.m2/settings.xml \
    && echo "</settings>" >> /root/.m2/settings.xml \

    ## motd
    && echo "pub 创建并获取公钥" >> /etc/motd \

    ## 最终
    && echo "succssful"


    ### 启动服务
#    && systemctl start sshd

EXPOSE 22
CMD ["/usr/sbin/init"]


